package org.example.big_data.config;

import org.example.big_data.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    LoginInterceptor loginInterceptor;  //欲注入的拦截器类
    @Override
    public void addInterceptors(InterceptorRegistry registry) {  //addInterceptors方法用于注册拦截器
        //参数registry它是一个拦截器注册表，用于注册拦截器，调用addInterceptor方法添加拦截器类
        registry.addInterceptor(loginInterceptor)
              //.addPathPatterns("/**");
                .excludePathPatterns("/user/register","/user/login");
        //链式调用addPathPatterns方法添加拦截路径
        //链式调用excludePathPatterns方法对哪些路径不拦截，除此以外全部拦截
        //二者是互斥的不能同时写
    }


}
